package com.bjtu.literatureclient.base.handler;

import com.bjtu.literatureclient.base.exceptions.BaseException;
import com.bjtu.literatureclient.base.result.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author caiyuli
 * @date 2020-02-18 19:44
 */

@ControllerAdvice("com.example.literaturesystem.controller")
public class BaseExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(BaseExceptionHandler.class);



    @ExceptionHandler(value = BaseException.class)
    @ResponseBody
    public Result handlerSellerException(BaseException e){
        logger.debug(e.getMessage());
        return Result.fail(e.getCode(),e.getMessage());
    }

}
